home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0090_Reading Multiple Keys.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  2KB  |  70 lines

  1. {
  2. > There has been MANY times that I've wanted to read MORE THAN ONE key at
  3. > the same time.. with ReadKey, it seems impossible!  For programming games,
  4. > it seems fall quite short!  So I began to look directly at the
  5. > keyboard buffer..  but it all seemed to be CRIPTIC!
  6. With readkey it is impossible. The keyboard buffer doesnt help either. Take a
  7. look at this code:
  8. }
  9.  
  10. {$M 2000,0,0}
  11. {$R-,S-,I-,D-,F+,V-,B-,N-,L+}
  12. Program BinClock;
  13. Uses DOS,CRT;
  14. Var Old_Keyb:Pointer;
  15.     Keyz:Set Of 0..127;
  16.     Loop:Byte;
  17.  
  18. Procedure STI;
  19.  Inline($FB);
  20.  
  21. Procedure CLI;
  22.  Inline($FA);
  23.  
  24. Procedure CallOld(Sub:Pointer);
  25.  Begin
  26.   Inline($9C/$FF/$5E/$06);
  27.  End;
  28.  
  29. Procedure My_Keyb;
  30.  Interrupt;
  31. Var B:Byte;
  32. Begin
  33.  CallOld(Old_Keyb);
  34.  B:=Port[$60];
  35.  If B>=$80 Then
  36.   Keyz:=Keyz-[B And $7F]
  37.  Else
  38.   Keyz:=Keyz+[B];
  39.  STI;
  40. End;
  41.  
  42. Begin
  43.  ClrScr;
  44.  Keyz:=[];
  45.  GetIntVec($09,Old_Keyb);
  46.  SetIntVec($09,@My_Keyb);
  47.  Repeat
  48.   While KeyPressed Do
  49.    If ReadKey=#0 Then;
  50.   GotoXY(1,1);
  51.   ClrEol;
  52.   For Loop:=1 To 127 Do
  53.    Begin
  54.     If Loop In Keyz Then
  55.      Write('*',Loop,'*');
  56.    End;
  57.  Until 1 In Keyz;
  58. End.
  59.  
  60. {
  61. > Did I miss something is KBD 101 class?  Could anyone here shed some light
  62. > on  this.. a lookup chart would be a great thing, but algorithms are
  63. > useful too ;)
  64.  
  65. each key has it's own number. On the origonal PC keyboard,you start at <ESC>
  66. (1) and read across... <!>=2, <@>=3 (I've used shifted to diferentiate
  67. between the key 2 and the scancode 2 etc), then down... but that got shifted
  68. around... I usually use the above program to find the correct key, then code
  69. it into my prog...
  70. }